<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用对象的方式实现数组</title>
</head>
<body>
	<h1>用对象的方式实现数组</h1><hr>
	<script type="text/javascript">
		//构造数组函数
		function MyArray(size) {
			this.length = size;
			for(var i=0; i<size; i++) {
				this[i] = "";
			}
		}
		//给元素赋值
		var Num, str = "<tr>";
		var arr = new MyArray(Num);
		for(Num=0; Num<10; Num++) {
			arr[Num] = Num*Num;
		}
		//输出表格现实
		for(Num in arr) {
			str += "<td>arr[" + Num + "]=" + arr[Num] + "<br></td></tr>"
			document.write(arr[Num] + " ");
		}
		document.write("<table border='1'>");
		document.write(str);
		document.write("</table>");

	</script>
</body>
</html>